<template>
  <!--  边框-->
  <div class="biankuang" style="width: 45rem;height: 35rem;margin: 10rem;">
    <!--    登录二字-->
    <div class="font" style="font-size: xxx-large;">
      登录
    </div>
    <!--    账号密码输入框，带验证-->
    <div style="width: 40rem;padding-top: 3rem;padding-left: 10rem;padding-right: 5rem">
      <el-form :model="loginForm" status-icon :rules="rules" ref="loginForm" size="large">
        <el-form-item label="账号&nbsp;&nbsp;&nbsp;" prop="checkAccount">
          <el-input type="text" v-model="loginForm.checkAccount" placeholder="请输入账号"></el-input>
        </el-form-item>
        <el-form-item label="密码&nbsp;&nbsp;&nbsp;" prop="checkPwd">
          <el-input type="password" v-model="loginForm.checkPwd" placeholder="请输入密码"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="this.login('loginForm')" style="margin: auto">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>

</template>

<script>
import request from "/src/utils/request.js";

export default {
  name: "Login",
  data() {
    return {
      // 验证码
      viewCode: '',
      // 登录信息/验证信息
      loginForm: {
        checkAccount: '',
        checkPwd: '',
      },
      rules: {
        checkPwd: [
          {required: true, trigger: 'blur', message: "密码不能为空"}
        ],
        checkAccount: [
          {required: true, trigger: 'blur', message: "请输入账号"}
        ]
      },
    };
  },
  methods: {
    // 登录按钮
    login() {
      // 像后端发请求
      request.get("/user/login?account=" + this.loginForm.checkAccount + "&userPwd=" + this.loginForm.checkPwd).then(res => {
        if (res.data.code === "200") {
          sessionStorage.setItem("user", JSON.stringify(res.data.data));
          this.$router.push("/home")
        } else {
          this.$message.error("用户名/密码错误")
          return;
        }
      })
    },

  },

}
</script>

<style scoped>
.biankuang {
  border-radius: 37px;
  background: #e0e0e0;
}

.font {
  /*字体位置*/
  padding-left: 45%;
  padding-top: 10%;
  /*字体样式设置*/
  text-shadow: 0 0 2px hsl(40, 28.57%, 28.82%), 0 0 2px hsl(40, 28.57%, 28.82%), 0 0 2px hsl(40, 28.57%, 28.82%); /*多个叠加*/
  font-size: 35px;
  color: #fff;
}

</style>